package cn.csc.module.order.dal.mysql.returns;

import java.util.*;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.module.order.dal.dataobject.returns.OrderReturnsDO;
import org.apache.ibatis.annotations.Mapper;
import cn.csc.module.order.controller.admin.returns.vo.*;

/**
 * 订单退换货 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface OrderReturnsMapper extends BaseMapperX<OrderReturnsDO> {

    default PageResult<OrderReturnsDO> selectPage(OrderReturnsPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderReturnsDO>()
                .eqIfPresent(OrderReturnsDO::getReturnsNo, reqVO.getReturnsNo())
                .eqIfPresent(OrderReturnsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderReturnsDO::getExpressNo, reqVO.getExpressNo())
                .likeIfPresent(OrderReturnsDO::getConsigneeRealname, reqVO.getConsigneeRealname())
                .eqIfPresent(OrderReturnsDO::getConsigneePhone, reqVO.getConsigneePhone())
                .eqIfPresent(OrderReturnsDO::getConsigneePhoneSpare, reqVO.getConsigneePhoneSpare())
                .eqIfPresent(OrderReturnsDO::getConsigneeAddress, reqVO.getConsigneeAddress())
                .eqIfPresent(OrderReturnsDO::getConsigneeZip, reqVO.getConsigneeZip())
                .eqIfPresent(OrderReturnsDO::getLogisticsType, reqVO.getLogisticsType())
                .eqIfPresent(OrderReturnsDO::getLogisticsFee, reqVO.getLogisticsFee())
                .eqIfPresent(OrderReturnsDO::getOrderLogisticsStatus, reqVO.getOrderLogisticsStatus())
                .eqIfPresent(OrderReturnsDO::getLogisticsSettlementStatus, reqVO.getLogisticsSettlementStatus())
                .eqIfPresent(OrderReturnsDO::getLogisticsResultLast, reqVO.getLogisticsResultLast())
                .eqIfPresent(OrderReturnsDO::getLogisticsResult, reqVO.getLogisticsResult())
                .betweenIfPresent(OrderReturnsDO::getLogisticsCreateTime, reqVO.getLogisticsCreateTime())
                .betweenIfPresent(OrderReturnsDO::getLogisticsUpdateTime, reqVO.getLogisticsUpdateTime())
                .betweenIfPresent(OrderReturnsDO::getLogisticsSettlementTime, reqVO.getLogisticsSettlementTime())
                .eqIfPresent(OrderReturnsDO::getReturnsType, reqVO.getReturnsType())
                .eqIfPresent(OrderReturnsDO::getHandlingWay, reqVO.getHandlingWay())
                .eqIfPresent(OrderReturnsDO::getReturnsAmount, reqVO.getReturnsAmount())
                .betweenIfPresent(OrderReturnsDO::getReturnSubmitTime, reqVO.getReturnSubmitTime())
                .betweenIfPresent(OrderReturnsDO::getHandlingTime, reqVO.getHandlingTime())
                .eqIfPresent(OrderReturnsDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(OrderReturnsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderReturnsDO::getId));
    }

    default List<OrderReturnsDO> selectList(OrderReturnsExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<OrderReturnsDO>()
                .eqIfPresent(OrderReturnsDO::getReturnsNo, reqVO.getReturnsNo())
                .eqIfPresent(OrderReturnsDO::getOrderId, reqVO.getOrderId())
                .eqIfPresent(OrderReturnsDO::getExpressNo, reqVO.getExpressNo())
                .likeIfPresent(OrderReturnsDO::getConsigneeRealname, reqVO.getConsigneeRealname())
                .eqIfPresent(OrderReturnsDO::getConsigneePhone, reqVO.getConsigneePhone())
                .eqIfPresent(OrderReturnsDO::getConsigneePhoneSpare, reqVO.getConsigneePhoneSpare())
                .eqIfPresent(OrderReturnsDO::getConsigneeAddress, reqVO.getConsigneeAddress())
                .eqIfPresent(OrderReturnsDO::getConsigneeZip, reqVO.getConsigneeZip())
                .eqIfPresent(OrderReturnsDO::getLogisticsType, reqVO.getLogisticsType())
                .eqIfPresent(OrderReturnsDO::getLogisticsFee, reqVO.getLogisticsFee())
                .eqIfPresent(OrderReturnsDO::getOrderLogisticsStatus, reqVO.getOrderLogisticsStatus())
                .eqIfPresent(OrderReturnsDO::getLogisticsSettlementStatus, reqVO.getLogisticsSettlementStatus())
                .eqIfPresent(OrderReturnsDO::getLogisticsResultLast, reqVO.getLogisticsResultLast())
                .eqIfPresent(OrderReturnsDO::getLogisticsResult, reqVO.getLogisticsResult())
                .betweenIfPresent(OrderReturnsDO::getLogisticsCreateTime, reqVO.getLogisticsCreateTime())
                .betweenIfPresent(OrderReturnsDO::getLogisticsUpdateTime, reqVO.getLogisticsUpdateTime())
                .betweenIfPresent(OrderReturnsDO::getLogisticsSettlementTime, reqVO.getLogisticsSettlementTime())
                .eqIfPresent(OrderReturnsDO::getReturnsType, reqVO.getReturnsType())
                .eqIfPresent(OrderReturnsDO::getHandlingWay, reqVO.getHandlingWay())
                .eqIfPresent(OrderReturnsDO::getReturnsAmount, reqVO.getReturnsAmount())
                .betweenIfPresent(OrderReturnsDO::getReturnSubmitTime, reqVO.getReturnSubmitTime())
                .betweenIfPresent(OrderReturnsDO::getHandlingTime, reqVO.getHandlingTime())
                .eqIfPresent(OrderReturnsDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(OrderReturnsDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OrderReturnsDO::getId));
    }

}
